From 88bc5163bc31a31916c18dc50af09c17b9fe7996 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 24 Apr 2008 10:14:43 +0100 Subject: [PATCH] ioemu: Save PCI device INTx line states. Otherwise, ioemu can be out of sync with the hypervisor after restoring guest state, if INTx lines were asserted when the state was saved. This prevents ioemu from setting the line to zero in Xen (because it thinks the line is already zero). This can allow th eguest to enter an endless IRQ loop and hang. Signed-off-by: Kazuhiro Suzuki Signed-off-by: Keir Fraser --- tools/ioemu/hw/pci.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/ioemu/hw/pci.c b/tools/ioemu/hw/pci.c index 05329fe0ef..250dfcb3c9 100644 --- a/tools/ioemu/hw/pci.c +++ b/tools/ioemu/hw/pci.c @@ -79,18 +79,30 @@ int pci_bus_num(PCIBus *s) void pci_device_save(PCIDevice *s, QEMUFile *f) { - qemu_put_be32(f, 1); /* PCI device version */ + uint8_t irq_state = 0; + int i; + qemu_put_be32(f, 2); /* PCI device version */ qemu_put_buffer(f, s->config, 256); + for (i = 0; i < 4; i++) + irq_state |= !!s->irq_state[i] << i; + qemu_put_buffer(f, &irq_state, 1); } int pci_device_load(PCIDevice *s, QEMUFile *f) { uint32_t version_id; version_id = qemu_get_be32(f); - if (version_id != 1) + if (version_id != 1 && version_id != 2) return -EINVAL; qemu_get_buffer(f, s->config, 256); pci_update_mappings(s); + if (version_id == 2) { + uint8_t irq_state; + int i; + qemu_get_buffer(f, &irq_state, 1); + for (i = 0; i < 4; i++) + pci_set_irq(s, i, !!(irq_state >> i)); + } return 0; } -- 2.30.2